package com.android.love.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.android.love.R;

public class ColorformatAdapter extends BaseAdapter {
	private List<String> strs;
	private Context context;
	private int pos;

	public ColorformatAdapter(List<String> strs, Context context, int pos) {
		super();
		this.strs = strs;
		this.context = context;
		this.pos = pos;
	}

	@Override
	public int getCount() {
		return strs.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return strs.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null)
			convertView = View.inflate(context, R.layout.color_format_item,
					null);
		TextView tv_item = (TextView) convertView.findViewById(R.id.tv_item);
		tv_item.setText(strs.get(position));
		if (position == pos) {
			tv_item.setBackgroundResource(R.drawable.guige_on);
		} else {
			tv_item.setBackgroundResource(R.drawable.guige);
		}
		return convertView;
	}

	// /**
	// * 改变选择状态的方法
	// */
	// public void changeStatus(int select) {
	// for (int i = 0; i < strs.size(); i++) {
	// strs.get(i).setSelect(false);
	// }
	//
	// strs.get(select).setSelect(true);
	// }

	public void setPos(int pos) {
		this.pos = pos;
	}

}
